Telegram Group & Telegram Channel
Note #29 Testing.short или разделяем тестовые прогоны 📝

Недавно наткнулся на интересную тему: разделение Go тестов на быстрые или медленные те например unit и integration tests. Все собрал в короткую заметку:

A) Стандартный подход использую `testing.Short` [2]:
func TestQuick(t *testing.T) {
...
}

func TestTimeConsuming(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
}

Если выполнить:
$ go test -short
То мы пропустим тест TestTimeConsuming и выполним только TestQuick

B) Использовать build tags самый, на мой взгляд, гибкий подход:
Те создаем integration_test.go файл и добавляем билд тэги [1]:
// +build integration

func TestTimeConsuming(t *testing.T) {
// ...
}

Далее просто запускаем:
$ go test -tags=integration

С) Использовать -test.run RegExp [2]:
Можно именовать тесты с префиксом понятным всей команде:
func TestQuickUnit(t *testing.T) {
...
}

func TestIntegraion(t *testing.T) {
...
}

И далее просто:
$ go test -run Integration
$ go test -run Unit

P.S. еще как вариант можно добавить разделение с помощью переменных окружения
А как сделано в вашем проекте? Поделиться можно в личку или чат
Links:
[1] https://golang.org/pkg/go/build/
[2] https://golang.org/cmd/go/#hdr-Testing_flags
[3] https://golang.org/pkg/testing/



tg-me.com/golang_for_two/54
Create:
Last Update:

Note #29 Testing.short или разделяем тестовые прогоны 📝

Недавно наткнулся на интересную тему: разделение Go тестов на быстрые или медленные те например unit и integration tests. Все собрал в короткую заметку:

A) Стандартный подход использую `testing.Short` [2]:

func TestQuick(t *testing.T) {
...
}

func TestTimeConsuming(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
}

Если выполнить:
$ go test -short
То мы пропустим тест TestTimeConsuming и выполним только TestQuick

B) Использовать build tags самый, на мой взгляд, гибкий подход:
Те создаем integration_test.go файл и добавляем билд тэги [1]:
// +build integration

func TestTimeConsuming(t *testing.T) {
// ...
}

Далее просто запускаем:
$ go test -tags=integration

С) Использовать -test.run RegExp [2]:
Можно именовать тесты с префиксом понятным всей команде:
func TestQuickUnit(t *testing.T) {
...
}

func TestIntegraion(t *testing.T) {
...
}

И далее просто:
$ go test -run Integration
$ go test -run Unit

P.S. еще как вариант можно добавить разделение с помощью переменных окружения
А как сделано в вашем проекте? Поделиться можно в личку или чат
Links:
[1] https://golang.org/pkg/go/build/
[2] https://golang.org/cmd/go/#hdr-Testing_flags
[3] https://golang.org/pkg/testing/

BY 🇺🇦 Go for two :)


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/golang_for_two/54

View MORE
Open in Telegram


🇺🇦 Go на двоих Telegram | DID YOU KNOW?

Date: |

Telegram Auto-Delete Messages in Any Chat

Some messages aren’t supposed to last forever. There are some Telegram groups and conversations where it’s best if messages are automatically deleted in a day or a week. Here’s how to auto-delete messages in any Telegram chat. You can enable the auto-delete feature on a per-chat basis. It works for both one-on-one conversations and group chats. Previously, you needed to use the Secret Chat feature to automatically delete messages after a set time. At the time of writing, you can choose to automatically delete messages after a day or a week. Telegram starts the timer once they are sent, not after they are read. This won’t affect the messages that were sent before enabling the feature.

Telegram is riding high, adding tens of million of users this year. Now the bill is coming due.Telegram is one of the few significant social-media challengers to Facebook Inc., FB -1.90% on a trajectory toward one billion users active each month by the end of 2022, up from roughly 550 million today.

🇺🇦 Go на двоих from tw


Telegram 🇺🇦 Go for two :)
FROM USA